package com.polukeuro.app.tests;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.polukeuro.app.model.entity.Group;
import com.polukeuro.app.model.entity.Team;

public final class TestUtils {

	private static final Log LOG = LogFactory.getLog(TestUtils.class);
	
	private TestUtils() {
		LOG.warn("stubbed feature");
	}

	public static TestUtils getInstance() {
		return new TestUtils();
	}

	public static Group getGroupA() {

		Team poland = new Team(generateId(), "Poland", "POL");
		Team greece = new Team(generateId(), "Greece", "GRE");
		Team russia = new Team(generateId(), "Russia", "RUS");
		Team czechRepublic = new Team(generateId(), "Czech Republic", "CZE");

		List<Team> countries = new ArrayList<Team>();
		countries.add(poland);
		countries.add(greece);
		countries.add(russia);
		countries.add(czechRepublic);

		Group group = new Group(generateId(), "groupA", countries);
		return group;
	}

	public static Group getGroupB() {

		Team nederland = new Team(generateId(), "Holland", "NED");
		Team denmark = new Team(generateId(), "Danemark", "DEN");
		Team germany = new Team(generateId(), "Germany", "GER");
		Team portugal = new Team(generateId(), "Portugal", "POR");

		List<Team> countries = new ArrayList<Team>();
		countries.add(nederland);
		countries.add(denmark);
		countries.add(germany);
		countries.add(portugal);
		

		Group group = new Group(generateId(), "groupB", countries);
		return group;
	}

	public static Group getGroupC() {

		Team spain = new Team(generateId(), "Spain", "ESP");
		Team italy = new Team(generateId(), "Italy", "ITA");
		Team ireland = new Team(generateId(), "Ireland", "IRL");
		Team croatia = new Team(generateId(), "Croatia", "CRO");


		List<Team> countries = new ArrayList<Team>();
		countries.add(spain);
		countries.add(italy);
		countries.add(ireland);
		countries.add(croatia);

		Group group = new Group(generateId(), "groupC", countries);
		return group;
	}

	public static Group getGroupD() {

		Team ukrain = new Team(generateId(), "Ukrain", "UKR");
		Team sweden = new Team(generateId(), "Sweden", "SWE");
		Team france = new Team(generateId(), "France", "FRA");
		Team england = new Team(generateId(), "England", "ENG");
		
		List<Team> countries = new ArrayList<Team>();
		countries.add(ukrain);
		countries.add(sweden);
		countries.add(france);
		countries.add(england);

		Group group = new Group(generateId(), "groupD", countries);
		return group;
	}
	
	public static Group getGroup(String groupName) {
		Group group = null;
		if("A".equals(groupName)) {
			group = TestUtils.getGroupA();
		} else if("B".equals(groupName)) {
			group = TestUtils.getGroupB();
		} else if("C".equals(groupName)) {
			group = TestUtils.getGroupC();
		} else if("D".equals(groupName)) {
			group = TestUtils.getGroupD();
		} 
		return group;
	}
	

	public static List<Group> getGroups() {
		List<Group> groups = new ArrayList<Group>();
		groups.add(TestUtils.getGroupA());
		groups.add(TestUtils.getGroupB());
		groups.add(TestUtils.getGroupC());
		groups.add(TestUtils.getGroupD());
		return groups;
	}
	
	public static String generateId() {
		return UUID.randomUUID().toString();
	}
}
